package cn.rc.rcsystem.fallback;

import cn.rc.rcsystem.exception.GlobalExceptionCodeEnum;
import cn.rc.rcsystem.feign.UserService;
import cn.rc.rcsystem.result.JSONResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class UserServiceFallbackFactory implements FallbackFactory<UserService> {
    @Override
    public UserService create(Throwable throwable) {
        return new UserService() {
            @Override
            public JSONResult get(Long id) {
                return JSONResult.error(GlobalExceptionCodeEnum.FALLBACK);
            }
        };
    }
}
